# -*- coding: utf-8 -*-

import sys, time, os
import datetime

default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)

file_name = sys.argv[1]

old_str = sys.argv[2]
new_str = sys.argv[3]

print ('##file_name is %s, old_str = %s, new_str = %s ' % (file_name, old_str, new_str))

file_data = ''

with open(file_name, "r", encoding='UTF-8') as f:
    for line in f:
        if old_str in line:
            line = line.replace(old_str, new_str)
        file_data += line

with open(file_name,"w", encoding='UTF-8') as f:
    f.write(file_data)
